<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>验证码实验</title>
<!--  <script src="../static/axios.min.js"></script>-->
    <script src="https://unpkg.com/axios/dist/axios.min.js"></script>
</head>
<body>
<div>
  请输入验证码：<input type="text" placeholder="验证码">
  <img style="vertical-align: middle" src="/verification-image" onclick="this.src='/verification-image?r='+Math.random()">
  <input type="submit" value="登录">
</div>
<script>
  axios.defaults.baseURL=window.location.href
  document.querySelector("input[type=submit]").onclick=function (){
    let verf_code=document.querySelector("input").value
    axios.post('/verify',`code=${verf_code}`).then(r=>{
      console.log(r)
      if(r.data){
        alert("验证码输入正确")
      }else {
        document.querySelector("img").click()
      }
    })
  }
</script>
</body>
</html>